/*
 * @Author: 
 * @Date: 2022-08-27 09:30:22
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-08-29 17:25:40
 * @Description: file content
 * @FilePath: \vue3-vite-scss-template\src\router\index.js
 */
import { createRouter, createWebHashHistory } from "vue-router";
const routerContext = import.meta.globEager('./modules/*.js')
console.log(routerContext);
const asyncRoutes = [];
// routerContext.keys().forEach(route => {
//     if (route.startsWith("./index")) {
//         return false;
//     }
//     const routerModule = routerContext(route);
//     asyncRoutes.push(...(routerModule.routes));

// })
const routes = [{
    path: "/",
    redirect: "/visualization"
},
// ...asyncRoutes,
{
    path: "/userManage",
    name: "userManage",
    component: () => {
        return import("@/view/userManage/index.vue")
    }

},
{
    path: "/visualization",
    name: "Visualization",
    component: () => {
        return import("@/view/visualization/index.vue")
    }
},
];


const router = createRouter({
    history: createWebHashHistory(
        import.meta.env.BASE_URL),
    routes,
});

router.beforeEach((to, from, next) => {
    next()
})

export default router;